class Solution(object):
    def moveZeroes(self, nums):
        """
        :type nums: List[int]
        :rtype: void Do not return anything, modify nums in-place instead.
        """
        count = 0
        l = len(nums)
        for i in range(l):
            v = nums.pop(0)
            if v == 0:
                count += 1
                nums.append(v)
            else:
                if count == 0:
                    nums.append(v)
                else:
                    nums.insert(-count, v)

        return nums


s = Solution()
print(s.moveZeroes([1, 0, 1]))
print(s.moveZeroes([0, 1, 0, 3, 12]))
